<template>
  <div>
    <a-card :bordered="false">
      <!-- 主表单区域 -->
      <div class="btn">
        <a-button type="primary" @click="add">
          保存
        </a-button>
        <a-button type="primary" @click="reset">
          重置
        </a-button>
      </div>
      <a-form :form="form">
        <a-row>
          <a-col :xs="24" :sm="8">
            <a-form-item label="全宗号" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                v-decorator="['ysjQuanZongHao', validatorRules.ysjQuanZongHao]"
                placeholder="请输入全宗号"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="8">
            <a-form-item label="序号" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input-number v-decorator="['xuHao']" placeholder="请输入序号" style="width: 100%" />
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="8">
            <a-form-item label="归档年度" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                v-decorator="['ysjGuiDangNianDu', validatorRules.ysjGuiDangNianDu]"
                placeholder="请输入归档年度"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="8">
            <a-form-item label="档号" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['ysjDangHao']" placeholder="请输入档号"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="8">
            <a-form-item label="保管期限" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-dict-select-tag
                type="list"
                v-decorator="['ysjBaoGuanQiXian', validatorRules.ysjBaoGuanQiXian]"
                :trigger-change="true"
                dictCode="BaoGuanQiXian"
                placeholder="请选择保管期限"
              />
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="8">
            <a-form-item label="归档日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-date
                placeholder="请选择归档日期"
                v-decorator="['ysjGuiDangRiQi']"
                :trigger-change="true"
                style="width: 100%"
              />
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="8">
            <a-form-item label="归档机构" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                v-decorator="['ysjGuiDangJiGou', validatorRules.ysjGuiDangJiGou]"
                placeholder="请输入归档机构"
              ></a-input>
            </a-form-item>
          </a-col>
          <!-- 责任者/录入人 -->
          <a-col :xs="24" :sm="8">
            <a-form-item label="目录号" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['ysjMuLuHao']" placeholder="请输入目录号"></a-input>
            </a-form-item>
          </a-col>
          <!-- 问题分类 -->
          <a-col :xs="24" :sm="8">
            <a-form-item label="主题词" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['ysjZhuTiCi']" placeholder="请输入主题词"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="8">
            <a-form-item label="题名" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['ysjTiMing', validatorRules.ysjTiMing]" placeholder="请输入题名"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="8">
            <a-form-item label="起止张号" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['ysjQiZhiZhangHao']" placeholder="请输入起止张号"></a-input>
            </a-form-item>
          </a-col>
          <!-- 关键词 -->
          <a-col :xs="24" :sm="8">
            <a-form-item label="紧急程度" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-dict-select-tag
                type="list"
                v-decorator="['ysjJinJiChengDu']"
                :trigger-change="true"
                dictCode="JingJiChengDu"
                placeholder="请选择紧急程度"
              />
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="8">
            <a-form-item label="密级" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-dict-select-tag
                type="list"
                v-decorator="['ysjMiJi', validatorRules.ysjMiJi]"
                :trigger-change="true"
                dictCode="MiJi"
                placeholder="请选择密级"
              />
            </a-form-item>
          </a-col>
          <!-- 存放位置/摄影者/摄影时间 -->
          <a-col :xs="24" :sm="8">
            <a-form-item label="主题词" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['ysjZhuTiCi']" placeholder="请输入主题词"></a-input>
            </a-form-item>
          </a-col>
          <!-- 摄影地点 -->
          <a-col :xs="24" :sm="8">
            <a-form-item label="人物" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['ysjRenWu']" placeholder="请输入人物"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="8">
            <a-form-item label="分类号" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['ysjFenLeiHao']" placeholder="请输入分类号"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="8">
            <a-form-item label="文字说明" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['ysjWenZiShuoMing']" placeholder="请输入文字说明"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="8">
            <a-form-item label="册号" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['ysjCeHao']" placeholder="请输入册号"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="8">
            <a-form-item label="组内张数" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['ysjZuNeiZhangShu']" placeholder="请输入组内张数"></a-input>
            </a-form-item>
          </a-col>

          <a-col :xs="24" :sm="8">
            <a-form-item label="类型规格" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-dict-select-tag
                type="list"
                v-decorator="['ysjLeiXingGuiGe']"
                :trigger-change="true"
                dictCode="LeiXingGuiGe"
                placeholder="请选择类型规格"
              />
            </a-form-item>
          </a-col>
          <!-- 备注 -->
        </a-row>
      </a-form>
    </a-card>
  </div>
</template>

<script>
import pick from 'lodash.pick'
import { JeecgListMinxinPost } from '@/mixins/JeecgListMinxinPost'
import '@/assets/less/TableExpand.less'
import { WsEdit, queryById } from '@/api/api'
import JDate from '@/components/jeecg/JDate'

export default {
  name: 'infoList',
  mixins: [JeecgListMinxinPost],
  components: {
    JDate
  },
  data() {
    return {
      // headers: {
      //   authorization: 'authorization-text',
      // },
      // keyIndex: sessionStorage.getItem('keyIndex') ? sessionStorage.getItem('keyIndex') : 1,
      validatorRules: {
        liDangDnWeiMingCheng: {
          rules: [{ required: true, message: '请输入立档单位名称!' }]
        },
        quanZongHao: {
          rules: [{ required: true, message: '请输入全宗号!' }]
        },
        muLuHao: {
          rules: [{ required: true, message: '请输入目录号!' }]
        },
        nianDu: {
          rules: [{ required: true, message: '请输入年度!' }]
        },
        baoGuanQiXian: {
          rules: [{ required: true, message: '请输入保管期限!' }]
        },
        tiMing: {
          rules: [{ required: true, message: '请输入题名!' }]
        },
        miJi: {
          rules: [{ required: true, message: '请输入密级!' }]
        },
        yeShu: {
          rules: [{ required: true, message: '请输入页数!' }]
        },
        guiDangJiGou: {
          rules: [{ required: true, message: '请输入归档机构!' }]
        }
      },
      form: this.$form.createForm(this),
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },

      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '题号',
          dataIndex: 'actions',
          align: 'center',
          // fixed:"right",
          width: 147,
          scopedSlots: { customRender: 'actions' }
        },
        {
          title: '文件编号',
          align: 'center',
          dataIndex: 'wenJianBianHao'
        },
        {
          title: '密级',
          align: 'center',
          dataIndex: 'miJi'
        },
        {
          title: '保管期限',
          align: 'center',
          dataIndex: 'baoGuanQiXian'
        },
        {
          title: '年度',
          align: 'center',
          dataIndex: 'nianDu'
        },
        {
          title: '归档机构',
          align: 'center',
          dataIndex: 'guiDangJiGou'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          // fixed:"right",
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],

      url: {
        list: '/wsWenShuDangAnController/gl/queryCorrelationList',
        delete: '/wsWenShuDangAnController/delete',
        deleteBatch: '/wsZhuWenShu/deleteBatch'
        // queryMovingLog:"/wsWenShuDangAnController/lz/queryMovingLog"
      }
    }
  },
  created: function() {
    this.details()
  },
  methods: {
    getMsgFormSon(val) {
      
    },
    callback(key) {
      console.log(key)
    },
    // 重置
    reset() {
      this.form.resetFields()
    },
    // validateError(msg){
    //         this.$message.error(msg)
    //       },
    //      popupCallback(row){
    //        this.form.setFieldsValue(pick(row,'juHeCengCi','laiYuan','dangAnGuanMingCheng','dangAnGuanDaiMa','quanZongMingCheng','liDangDnWeiMingCheng','dianZiWenJianHao','dangHao','quanZongHao','muLuHao','nianDu','baoGuanQiXian','jiGOuHuoWenTi','leiBeiHao','shiBianAnJuanHao','guanBianAnJuanHao','shiBianJianHao','guanBianJuanHao','wenDangXuHao','yeHao','neiRongMiaoShu','tiMing','bingLieTiMing','fuTiMing','shuoMingTiMingWenZi','zhuTiCi','guanJianCi','renMing','zhaiYao','fenLeiHao','wenJianBianHao','zeRenZhe','riQi','wenZhong','jinJiChengDu','zhuSong','chaoSong','miJi','baoMiQiXian','xingShiTeZheng','wenJianZuHeLeiXing','jianShu','yeShu','yuZhong','gaoBen','quanXianGuanLi','zhiShiChanQuanShuoMing','shouQuanDuiXiang','shouQuanXingWei','kongZhiBiaoShi','guiDangJiGou'))
    //      },
    // 详情
    details() {
      if (this.$route.query.id) {
        queryById({
          id: this.$route.query.id
        }).then(res => {
          if (res.success) {
            let list = res.result
            setTimeout(() => {
              //  this.form.setFieldsValue(pick(this.mdl, 'note', 'mark'))

              this.form.setFieldsValue({
                quanZongHao: list.quanZongHao,
                wenDangXuHao: list.wenDangXuHao,
                nianDu: list.nianDu,
                dangHao: list.dangHao,
                baoGuanQiXian: list.baoGuanQiXian,
                riQi: list.riQi,
                guiDangJiGou: list.guiDangJiGou,
                liDangDnWeiMingCheng: list.liDangDnWeiMingCheng,
                guanJianCi: list.guanJianCi,
                zeRenZhe: list.zeRenZhe,
                yeHao: list.yeHao,
                zhuTiCi: list.zhuTiCi,
                jiGOuHuoWenTi: list.jiGOuHuoWenTi,
                muLuHao: list.muLuHao,
                tiMing: list.tiMing,
                wenZhong: list.wenZhong,
                wenJianBianHao: list.wenJianBianHao,
                jinJiChengDu: list.jinJiChengDu,
                miJi: list.miJi,
                yeShu: list.yeShu,
                jianShu: list.jianShu
              })
            }, 100)
          }
        })
      }
    },
    // 添加
    add() {
      if (!this.form.getFieldValue('quanZongHao')) {
        this.$message.info('请输入全宗号')
        return
      } else if (!this.form.getFieldValue('nianDu')) {
        this.$message.info('请输入年度')
        return
      } else if (!this.form.getFieldValue('baoGuanQiXian')) {
        this.$message.info('请输入保管期限')
        return
      } else if (!this.form.getFieldValue('guiDangJiGou')) {
        this.$message.info('请输入归档机构')
        return
      } else if (!this.form.getFieldValue('liDangDnWeiMingCheng')) {
        this.$message.info('请输入立党单位名称')
        return
      } else if (!this.form.getFieldValue('muLuHao')) {
        this.$message.info('请输入目录号')
        return
      } else if (!this.form.getFieldValue('tiMing')) {
        this.$message.info('请输入题名')
        return
      } else if (!this.form.getFieldValue('miJi')) {
        this.$message.info('请输入密级')
        return
      } else if (!this.form.getFieldValue('yeShu')) {
        this.$message.info('请输入页数!')
        return
      }
      let obj = {
        quanZongHao: this.form.getFieldValue('quanZongHao'),
        wenDangXuHao: this.form.getFieldValue('wenDangXuHao'),
        nianDu: this.form.getFieldValue('nianDu'),
        dangHao: this.form.getFieldValue('dangHao'),
        baoGuanQiXian: this.form.getFieldValue('baoGuanQiXian'),
        riQi: this.form.getFieldValue('riQi'),
        guiDangJiGou: this.form.getFieldValue('guiDangJiGou'),
        liDangDnWeiMingCheng: this.form.getFieldValue('liDangDnWeiMingCheng'),
        guanJianCi: this.form.getFieldValue('guanJianCi'),
        zeRenZhe: this.form.getFieldValue('zeRenZhe'),
        yeHao: this.form.getFieldValue('yeHao'),
        zhuTiCi: this.form.getFieldValue('zhuTiCi'),
        jiGOuHuoWenTi: this.form.getFieldValue('jiGOuHuoWenTi'),
        muLuHao: this.form.getFieldValue('muLuHao'),
        tiMing: this.form.getFieldValue('tiMing'),
        wenZhong: this.form.getFieldValue('wenZhong'),
        wenJianBianHao: this.form.getFieldValue('wenJianBianHao'),
        jinJiChengDu: this.form.getFieldValue('jinJiChengDu'),
        miJi: this.form.getFieldValue('miJi'),
        yeShu: this.form.getFieldValue('yeShu'),
        jianShu: this.form.getFieldValue('jianShu')
      }
      if (this.$route.query.id) {
        obj.id = this.$route.query.id
      }
      WsEdit(obj).then(res => {
        if (res.success) {
          this.$router.push('/wenshuList')
        }
      })
    }
  }
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';
.btn {
  width: 100%;
  text-align: right;
  margin: 10px 0;
  .ant-btn {
    margin-right: 30px;
  }
}
</style>
